package com.weiyuwqj.server.mapper;

import com.weiyuwqj.api.model.BusAssetPackagePlan;
import com.weiyuwqj.api.model.vo.BusAssetPackagePlanVO;
import com.weiyuwqj.api.util.converter.IntegerConverter;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Repository
public interface BusAssetPackagePlanMapper extends Mapper<BusAssetPackagePlan> {

    //更新状态
    int updatePackagePlanStatus(@Param(value = "oldStatus")Integer oldStatus,
                                @Param(value = "newStatus")Integer newStatus,
                                @Param(value = "planId") Integer planId);

    //更新满标时间
    int updateFullTime(Map map);

    //更新金额和进度
    int updateAmountAndScale(@Param(value = "amount")BigDecimal amount,
                             @Param(value = "onGoingAmount")BigDecimal onGoingAmount,
                             @Param(value = "scale")BigDecimal scale,
                             @Param(value = "planId")Integer planId);

    //资产包计划列表
    List<BusAssetPackagePlan> getPackagePlanList(BusAssetPackagePlan busAssetPackagePlan);

    List getListByPlanId(Integer packagePlanId);

    /**
     * 根据id修改还款时间
     * @param beforeRepayTime
     * @param id
     * @return
     */
    Integer modifyRepayTimeById(@Param(value = "beforeRepayTime")Date beforeRepayTime,@Param(value = "id")Integer id);

    /**
     * 根据id修改包状态
     * @param status 1-等待发布，2-投资中，3-已满标，4-已匹配审核
     * @param id
     * @return
     */
    Integer modifyStatusById(@Param(value = "status")Integer status,@Param(value = "id")Integer id);


    List<BusAssetPackagePlan> getPlanList();

    /**
     * 查询可投资的包计划
     * @return
     */
    List<BusAssetPackagePlan> getAssetPlanList();

    /**
     * 根据id查询单个信息
     * @param id
     * @return
     */
    BusAssetPackagePlanVO getAssetPackagePlanById(Integer id);

    /**
     * 根据包id和期数查询包计划
     * @param packageId
     * @param periods
     * @return
     */
    BusAssetPackagePlan getPlanByPackageIdAndPeriods(
            @Param(value = "packageId")Integer packageId,
            @Param(value = "periods")Integer periods);

    /**
     * 根据id修改发布时间
     * @param releaseTime
     * @param id
     * @return
     */
    Integer modifyPackagePlanByReleaseTime(@Param(value = "releaseTime")Date releaseTime,@Param(value = "id")Integer id);
}

